
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>基础 · 千锋大前端小册-Electron</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="古艺散人">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchors/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-insert-logo/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    

        
    
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="interview.html" />
    
    
    <link rel="prev" href="../" />
    

    
        <link rel="shortcut icon" href='../source/images/favicon.jpg' type="image/x-icon">
    
    
        <link rel="bookmark" href='../source/images/favicon.jpg' type="image/x-icon">
    
    
        <link rel="apple-touch-icon" href='../source/images/apple-touch-icon.jpg'>
    
    
        
        <link rel="apple-touch-icon" sizes="120x120" href="../source/images/apple-touch-icon.jpg">
        
        <link rel="apple-touch-icon" sizes="180x180" href="../source/images/apple-touch-icon.jpg">
        
    

    <style>
    @media only screen and (max-width: 640px) {
        .book-header .hidden-mobile {
            display: none;
        }
    }
    </style>
    <script>
        window["gitbook-plugin-github-buttons"] = {"buttons":[{"user":"lurongtao","repo":"felixbooks-kbone","type":"star","size":"small","count":true}]};
    </script>

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    前言
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.2" data-path="interview.html">
            
                <a href="interview.html">
            
                    
                    基础
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.2.1" data-path="interview.html">
            
                <a href="interview.html">
            
                    
                    interview
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../thanks/">
            
                <a href="../thanks/">
            
                    
                    感谢
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >基础</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#&#x9762;&#x8BD5;&#x771F;&#x9898;"><b></b>&#x9762;&#x8BD5;&#x771F;&#x9898;</a></li><ul><ul><li><span class="title-icon "></span><a href="#&#x4E00;&#x3001;&#x624B;&#x5199;&#x4E00;&#x4E2A;&#x6DF1;&#x514B;&#x9686;&#xFF0C;&#x4E0D;&#x80FD;&#x7528;jsonparse"><b></b>&#x4E00;&#x3001;&#x624B;&#x5199;&#x4E00;&#x4E2A;&#x6DF1;&#x514B;&#x9686;&#xFF0C;&#x4E0D;&#x80FD;&#x7528;json.parse</a></li><li><span class="title-icon "></span><a href="#&#x4E8C;&#x3001;call-apply-bind-&#x533A;&#x522B;&#xFF0C;&#x624B;&#x5199;-bind"><b></b>&#x4E8C;&#x3001;call apply bind &#x533A;&#x522B;&#xFF0C;&#x624B;&#x5199; bind</a></li><li><span class="title-icon "></span><a href="#&#x4E09;&#x3001;&#x51FD;&#x6570;&#x67EF;&#x91CC;&#x5316;&#x4E0E;&#x53CD;&#x67EF;&#x91CC;&#x5316;"><b></b>&#x4E09;&#x3001;&#x51FD;&#x6570;&#x67EF;&#x91CC;&#x5316;&#x4E0E;&#x53CD;&#x67EF;&#x91CC;&#x5316;</a></li></ul></ul></ul></div><a href="#&#x9762;&#x8BD5;&#x771F;&#x9898;" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="&#x9762;&#x8BD5;&#x771F;&#x9898;"><a name="&#x9762;&#x8BD5;&#x771F;&#x9898;" class="anchor-navigation-ex-anchor" href="#&#x9762;&#x8BD5;&#x771F;&#x9898;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x9762;&#x8BD5;&#x771F;&#x9898;" class="plugin-anchor" href="#&#x9762;&#x8BD5;&#x771F;&#x9898;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x9762;&#x8BD5;&#x771F;&#x9898;</h1>
<h3 id="&#x4E00;&#x3001;&#x624B;&#x5199;&#x4E00;&#x4E2A;&#x6DF1;&#x514B;&#x9686;&#xFF0C;&#x4E0D;&#x80FD;&#x7528;jsonparse"><a name="&#x4E00;&#x3001;&#x624B;&#x5199;&#x4E00;&#x4E2A;&#x6DF1;&#x514B;&#x9686;&#xFF0C;&#x4E0D;&#x80FD;&#x7528;jsonparse" class="anchor-navigation-ex-anchor" href="#&#x4E00;&#x3001;&#x624B;&#x5199;&#x4E00;&#x4E2A;&#x6DF1;&#x514B;&#x9686;&#xFF0C;&#x4E0D;&#x80FD;&#x7528;jsonparse"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x4E00;&#x3001;&#x624B;&#x5199;&#x4E00;&#x4E2A;&#x6DF1;&#x514B;&#x9686;&#xFF0C;&#x4E0D;&#x80FD;&#x7528;jsonparse" class="plugin-anchor" href="#&#x4E00;&#x3001;&#x624B;&#x5199;&#x4E00;&#x4E2A;&#x6DF1;&#x514B;&#x9686;&#xFF0C;&#x4E0D;&#x80FD;&#x7528;jsonparse"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E00;&#x3001;&#x624B;&#x5199;&#x4E00;&#x4E2A;&#x6DF1;&#x514B;&#x9686;&#xFF0C;&#x4E0D;&#x80FD;&#x7528;json.parse</h3>
<h5 id="1&#x3001;&#x5982;&#x679C;&#x4F7F;&#x7528;jsonparse"><a name="1&#x3001;&#x5982;&#x679C;&#x4F7F;&#x7528;jsonparse" class="anchor-navigation-ex-anchor" href="#1&#x3001;&#x5982;&#x679C;&#x4F7F;&#x7528;jsonparse"><i class="fa fa-link" aria-hidden="true"></i></a><a name="1&#x3001;&#x5982;&#x679C;&#x4F7F;&#x7528;jsonparse" class="plugin-anchor" href="#1&#x3001;&#x5982;&#x679C;&#x4F7F;&#x7528;jsonparse"><i class="fa fa-link" aria-hidden="true"></i></a>1&#x3001;&#x5982;&#x679C;&#x4F7F;&#x7528;json.parse</h5>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> test = {
  person: {
    firstname: {
      first: <span class="hljs-string">&apos;&#x5F20;&apos;</span>,
    },
    lastname: <span class="hljs-string">&apos;&#x5E08;&#x5085;&apos;</span>
  },
  age: <span class="hljs-number">40</span>,
  friend: [<span class="hljs-string">&apos;&#x5C0F;&#x674E;&apos;</span>, <span class="hljs-string">&apos;&#x5C0F;&#x8D75;&apos;</span>]
}
<span class="hljs-keyword">var</span> result = <span class="hljs-built_in">JSON</span>.parse(<span class="hljs-built_in">JSON</span>.stringify(test))
result.age = <span class="hljs-number">30</span>
result.person.firstname.first = <span class="hljs-string">&apos;&#x738B;&apos;</span>
result.friend.push(<span class="hljs-string">&apos;&#x5C0F;&#x9EC4;&apos;</span>)
<span class="hljs-built_in">console</span>.dir(test)
<span class="hljs-built_in">console</span>.dir(result)
</code></pre>
<h5 id="2&#x3001;&#x624B;&#x5199;&#x6DF1;&#x514B;&#x9686;"><a name="2&#x3001;&#x624B;&#x5199;&#x6DF1;&#x514B;&#x9686;" class="anchor-navigation-ex-anchor" href="#2&#x3001;&#x624B;&#x5199;&#x6DF1;&#x514B;&#x9686;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="2&#x3001;&#x624B;&#x5199;&#x6DF1;&#x514B;&#x9686;" class="plugin-anchor" href="#2&#x3001;&#x624B;&#x5199;&#x6DF1;&#x514B;&#x9686;"><i class="fa fa-link" aria-hidden="true"></i></a>2&#x3001;&#x624B;&#x5199;&#x6DF1;&#x514B;&#x9686;</h5>
<pre><code class="lang-js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">deepClone</span>(<span class="hljs-params">obj</span>)</span>{
  <span class="hljs-keyword">var</span> cloneObj
  <span class="hljs-comment">//&#x5F53;&#x8F93;&#x5165;&#x6570;&#x636E;&#x4E3A;&#x7B80;&#x5355;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x65F6;&#x76F4;&#x63A5;&#x590D;&#x5236;</span>
  <span class="hljs-keyword">if</span> (obj &amp;&amp; <span class="hljs-keyword">typeof</span> obj !==<span class="hljs-string">&apos;object&apos;</span> ) {
    cloneObj = obj
  }
  <span class="hljs-comment">//&#x5F53;&#x8F93;&#x5165;&#x6570;&#x636E;&#x4E3A;&#x5BF9;&#x8C61;&#x6216;&#x6570;&#x7EC4;&#x65F6;</span>
  <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (obj &amp;&amp; <span class="hljs-keyword">typeof</span> obj===<span class="hljs-string">&apos;object&apos;</span>) {
    <span class="hljs-comment">//&#x68C0;&#x6D4B;&#x8F93;&#x5165;&#x6570;&#x636E;&#x662F;&#x6570;&#x7EC4;&#x8FD8;&#x662F;&#x5BF9;&#x8C61;</span>
    cloneObj = <span class="hljs-built_in">Array</span>.isArray(obj) ? [] : {}
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> key <span class="hljs-keyword">in</span> obj) {
      <span class="hljs-keyword">if</span> (obj.hasOwnProperty(key)) {
        <span class="hljs-keyword">if</span> (obj[key] &amp;&amp; <span class="hljs-keyword">typeof</span> obj[key] === <span class="hljs-string">&apos;object&apos;</span>) {
          <span class="hljs-comment">//&#x82E5;&#x5F53;&#x524D;&#x5143;&#x7D20;&#x7C7B;&#x578B;&#x4E3A;&#x5BF9;&#x8C61;&#x65F6;&#xFF0C;&#x9012;&#x5F52;&#x8C03;&#x7528;</span>
          cloneObj[key] = deepClone(obj[key])
        }
        <span class="hljs-comment">//&#x82E5;&#x5F53;&#x524D;&#x5143;&#x7D20;&#x7C7B;&#x578B;&#x4E3A;&#x57FA;&#x672C;&#x6570;&#x636E;&#x7C7B;&#x578B;</span>
        <span class="hljs-keyword">else</span> {
          cloneObj[key] = obj[key]
        }
      }
    }
  }
  <span class="hljs-keyword">return</span> cloneObj
}

<span class="hljs-comment">// &#x6D4B;&#x8BD5;&#x7528;&#x4F8B;</span>
deepClone({
  x: <span class="hljs-number">1</span>,
  y: [ <span class="hljs-number">5</span>, <span class="hljs-number">6</span>, <span class="hljs-number">7</span> ],
  z: {
    a: <span class="hljs-number">0</span>,
    b: <span class="hljs-number">1</span>
  }
})
</code></pre>
<h3 id="&#x4E8C;&#x3001;call-apply-bind-&#x533A;&#x522B;&#xFF0C;&#x624B;&#x5199;-bind"><a name="&#x4E8C;&#x3001;call-apply-bind-&#x533A;&#x522B;&#xFF0C;&#x624B;&#x5199;-bind" class="anchor-navigation-ex-anchor" href="#&#x4E8C;&#x3001;call-apply-bind-&#x533A;&#x522B;&#xFF0C;&#x624B;&#x5199;-bind"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x4E8C;&#x3001;call-apply-bind-&#x533A;&#x522B;&#xFF0C;&#x624B;&#x5199;-bind" class="plugin-anchor" href="#&#x4E8C;&#x3001;call-apply-bind-&#x533A;&#x522B;&#xFF0C;&#x624B;&#x5199;-bind"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E8C;&#x3001;call apply bind &#x533A;&#x522B;&#xFF0C;&#x624B;&#x5199; bind</h3>
<h5 id="1&#x3001;&#x8C03;&#x7528;&#x65B9;&#x6CD5;"><a name="1&#x3001;&#x8C03;&#x7528;&#x65B9;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#1&#x3001;&#x8C03;&#x7528;&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="1&#x3001;&#x8C03;&#x7528;&#x65B9;&#x6CD5;" class="plugin-anchor" href="#1&#x3001;&#x8C03;&#x7528;&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>1&#x3001;&#x8C03;&#x7528;&#x65B9;&#x6CD5;</h5>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> xw = {
  name: <span class="hljs-string">&quot;&#x5C0F;&#x738B;&quot;</span>,
  gender: <span class="hljs-string">&quot;&#x7537;&quot;</span>,
  age: <span class="hljs-number">24</span>,
  say: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-keyword">this</span>.name + <span class="hljs-string">&quot;, &quot;</span> + <span class="hljs-keyword">this</span>.gender + <span class="hljs-string">&quot;, &#x4ECA;&#x5E74;&quot;</span> + <span class="hljs-keyword">this</span>.age)
  }
}
<span class="hljs-keyword">var</span> xh = {
  name: <span class="hljs-string">&quot;&#x5C0F;&#x7EA2;&quot;</span>,
  gender: <span class="hljs-string">&quot;&#x5973;&quot;</span>,
  age: <span class="hljs-number">18</span>
}

xw.say()
xw.say.call(xh)
xw.say.apply(xh)
xw.say.bind(xh)()
</code></pre>
<h5 id="2&#x3001;&#x4F20;&#x53C2;"><a name="2&#x3001;&#x4F20;&#x53C2;" class="anchor-navigation-ex-anchor" href="#2&#x3001;&#x4F20;&#x53C2;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="2&#x3001;&#x4F20;&#x53C2;" class="plugin-anchor" href="#2&#x3001;&#x4F20;&#x53C2;"><i class="fa fa-link" aria-hidden="true"></i></a>2&#x3001;&#x4F20;&#x53C2;</h5>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> xw = {
  name: <span class="hljs-string">&quot;&#x5C0F;&#x738B;&quot;</span>,
  gender: <span class="hljs-string">&quot;&#x7537;&quot;</span>,
  age: <span class="hljs-number">24</span>,
  say: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">school,grade</span>) </span>{
    alert(<span class="hljs-keyword">this</span>.name + <span class="hljs-string">&quot;, &quot;</span> + <span class="hljs-keyword">this</span>.gender + <span class="hljs-string">&quot;, &#x4ECA;&#x5E74;&quot;</span> + <span class="hljs-keyword">this</span>.age + <span class="hljs-string">&quot;, &#x5728;&quot;</span> + school + <span class="hljs-string">&quot;&#x4E0A;&quot;</span> + grade)
  }
}
<span class="hljs-keyword">var</span> xh = {
  name: <span class="hljs-string">&quot;&#x5C0F;&#x7EA2;&quot;</span>,
  gender: <span class="hljs-string">&quot;&#x5973;&quot;</span>,
  age: <span class="hljs-number">18</span>
}

xw.say.call(xh,<span class="hljs-string">&quot;&#x5B9E;&#x9A8C;&#x5C0F;&#x5B66;&quot;</span>,<span class="hljs-string">&quot;&#x516D;&#x5E74;&#x7EA7;&quot;</span>)
xw.say.apply(xh,[<span class="hljs-string">&quot;&#x5B9E;&#x9A8C;&#x5C0F;&#x5B66;&quot;</span>,<span class="hljs-string">&quot;&#x516D;&#x5E74;&#x7EA7;&quot;</span>])

xw.say.bind(xh,<span class="hljs-string">&quot;&#x5B9E;&#x9A8C;&#x5C0F;&#x5B66;&quot;</span>,<span class="hljs-string">&quot;&#x516D;&#x5E74;&#x7EA7;&quot;</span>)()
<span class="hljs-comment">// &#x6216;&#x8005; </span>
xw.say.bind(xh)(<span class="hljs-string">&quot;&#x5B9E;&#x9A8C;&#x5C0F;&#x5B66;&quot;</span>,<span class="hljs-string">&quot;&#x516D;&#x5E74;&#x7EA7;&quot;</span>)
</code></pre>
<h5 id="3&#x3001;&#x603B;&#x7ED3;&#x4E00;&#x4E0B;"><a name="3&#x3001;&#x603B;&#x7ED3;&#x4E00;&#x4E0B;" class="anchor-navigation-ex-anchor" href="#3&#x3001;&#x603B;&#x7ED3;&#x4E00;&#x4E0B;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="3&#x3001;&#x603B;&#x7ED3;&#x4E00;&#x4E0B;" class="plugin-anchor" href="#3&#x3001;&#x603B;&#x7ED3;&#x4E00;&#x4E0B;"><i class="fa fa-link" aria-hidden="true"></i></a>3&#x3001;&#x603B;&#x7ED3;&#x4E00;&#x4E0B;</h5>
<p>&#x5171;&#x540C;&#x70B9;&#x5C31;&#x662F;&#x4FEE;&#x6539; <code>this</code> &#x6307;&#x5411;&#xFF0C;&#x4E0D;&#x540C;&#x70B9;&#x5C31;&#x662F;&#xFF1A;</p>
<ul>
<li><code>call()</code>&#x548C;<code>apply()</code>&#x662F;&#x7ACB;&#x523B;&#x6267;&#x884C;&#x7684;&#xFF0C;&#x800C;<code>bind()</code>&#x662F;&#x8FD4;&#x56DE;&#x4E86;&#x4E00;&#x4E2A;&#x51FD;&#x6570;</li>
<li><code>call</code>&#x5219;&#x53EF;&#x4EE5;&#x4F20;&#x9012;&#x591A;&#x4E2A;&#x53C2;&#x6570;&#xFF0C;&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x548C;<code>apply</code>&#x4E00;&#x6837;&#xFF0C;&#x662F;&#x7528;&#x6765;&#x66FF;&#x6362;&#x7684;&#x5BF9;&#x8C61;&#xFF0C;&#x540E;&#x8FB9;&#x662F;&#x53C2;&#x6570;&#x5217;&#x8868;&#x3002;</li>
<li><code>apply</code>&#x6700;&#x591A;&#x53EA;&#x80FD;&#x6709;&#x4E24;&#x4E2A;&#x53C2;&#x6570;&#x2014;&#x2014;&#x65B0;<code>this</code>&#x5BF9;&#x8C61;&#x548C;&#x4E00;&#x4E2A;&#x6570;&#x7EC4;<code>argArray</code></li>
</ul>
<h5 id="4&#x3001;this&#x7ED1;&#x5B9A;&#x89C4;&#x5219;"><a name="4&#x3001;this&#x7ED1;&#x5B9A;&#x89C4;&#x5219;" class="anchor-navigation-ex-anchor" href="#4&#x3001;this&#x7ED1;&#x5B9A;&#x89C4;&#x5219;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="4&#x3001;this&#x7ED1;&#x5B9A;&#x89C4;&#x5219;" class="plugin-anchor" href="#4&#x3001;this&#x7ED1;&#x5B9A;&#x89C4;&#x5219;"><i class="fa fa-link" aria-hidden="true"></i></a>4&#x3001;this&#x7ED1;&#x5B9A;&#x89C4;&#x5219;</h5>
<ul>
<li>&#x9ED8;&#x8BA4;&#x7ED1;&#x5B9A;</li>
</ul>
<p>&#x72EC;&#x7ACB;&#x51FD;&#x6570;&#x8C03;&#x7528;&#x65F6;&#xFF0C; this &#x6307;&#x5411;&#x5168;&#x5C40;&#x5BF9;&#x8C61;&#xFF0C;&#x5982;&#x679C;&#x4F7F;&#x7528;&#x4E25;&#x683C;&#x6A21;&#x5F0F;&#xFF0C;&#x90A3;&#x4E48;&#x5168;&#x5C40;&#x5BF9;&#x8C61;&#x65E0;&#x6CD5;&#x4F7F;&#x7528;&#x9ED8;&#x8BA4;&#x7ED1;&#x5B9A;&#xFF0C; this &#x7ED1;&#x5B9A;&#x81F3; undefined &#x5E76;&#x629B;&#x9519;&#xFF08;TypeError: this is undefined&#xFF09;</p>
<ul>
<li>&#x9690;&#x5F0F;&#x7ED1;&#x5B9A;</li>
</ul>
<p>&#x5F53;&#x51FD;&#x6570;&#x4F5C;&#x4E3A;&#x5F15;&#x7528;&#x5C5E;&#x6027;&#x88AB;&#x6DFB;&#x52A0;&#x5230;&#x5BF9;&#x8C61;&#x4E2D;&#xFF0C;&#x9690;&#x5F0F;&#x7ED1;&#x5B9A;&#x89C4;&#x5219;&#x4F1A;&#x628A;&#x51FD;&#x6570;&#x8C03;&#x7528;&#x4E2D;&#x7684; this &#x7ED1;&#x5B9A;&#x5230;&#x8FD9;&#x4E2A;&#x4E0A;&#x4E0B;&#x6587;&#x5BF9;&#x8C61;</p>
<ul>
<li>&#x663E;&#x793A;&#x7ED1;&#x5B9A;</li>
</ul>
<p>&#x8FD0;&#x7528;apply call &#x65B9;&#x6CD5;&#xFF0C;&#x5728;&#x8C03;&#x7528;&#x51FD;&#x6570;&#x65F6;&#x5019;&#x7ED1;&#x5B9A;this&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x6307;&#x5B9A;&#x8C03;&#x7528;&#x7684;&#x51FD;&#x6570;&#x7684;this&#x503C;</p>
<ul>
<li>new&#x7ED1;&#x5B9A;</li>
</ul>
<p>&#x5C31;&#x662F;&#x4F7F;&#x7528;new&#x64CD;&#x4F5C;&#x7B26;&#x7684;&#x65F6;&#x5019;&#x7684;this&#x7ED1;&#x5B9A;&#x3002;</p>
<p>&#x4E0A;&#x8FF0;&#x56DB;&#x6761;&#x89C4;&#x5219;&#x4F18;&#x5148;&#x7EA7;&#x7531;&#x4E0A;&#x5230;&#x4E0B;&#x4F9D;&#x6B21;&#x9012;&#x589E;&#x3002;</p>
<h5 id="5&#x3001;&#x624B;&#x5199;-call"><a name="5&#x3001;&#x624B;&#x5199;-call" class="anchor-navigation-ex-anchor" href="#5&#x3001;&#x624B;&#x5199;-call"><i class="fa fa-link" aria-hidden="true"></i></a><a name="5&#x3001;&#x624B;&#x5199;-call" class="plugin-anchor" href="#5&#x3001;&#x624B;&#x5199;-call"><i class="fa fa-link" aria-hidden="true"></i></a>5&#x3001;&#x624B;&#x5199; call</h5>
<pre><code class="lang-js"><span class="hljs-built_in">Function</span>.prototype.myCall = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">context</span>) </span>{
  <span class="hljs-comment">// 1.&#x5224;&#x65AD;&#x6709;&#x6CA1;&#x6709;&#x4F20;&#x5165;&#x8981;&#x7ED1;&#x5B9A;&#x7684;&#x5BF9;&#x8C61;&#xFF0C;&#x6CA1;&#x6709;&#x9ED8;&#x8BA4;&#x662F;window&#xFF0C;&#x5982;&#x679C;&#x662F;&#x57FA;&#x672C;&#x7C7B;&#x578B;&#x7684;&#x8BDD;&#x901A;&#x8FC7;Object()&#x65B9;&#x6CD5;&#x8FDB;&#x884C;&#x8F6C;&#x6362;</span>
  <span class="hljs-keyword">var</span> context = <span class="hljs-built_in">Object</span>(context) || <span class="hljs-built_in">window</span>;

  <span class="hljs-comment">/**
    &#x5728;&#x6307;&#x5411;&#x7684;&#x5BF9;&#x8C61;obj&#x4E0A;&#x65B0;&#x5EFA;&#x4E00;&#x4E2A;fn&#x5C5E;&#x6027;&#xFF0C;&#x503C;&#x4E3A;this&#xFF0C;&#x4E5F;&#x5C31;&#x662F;fn()
    &#x76F8;&#x5F53;&#x4E8E;obj&#x53D8;&#x6210;&#x4E86;
    {
        value: &apos;hdove&apos;,
        fn: function fn() {
          console.log(this.value);
        }
    }
  */</span>
  context.fn = <span class="hljs-keyword">this</span>;

  <span class="hljs-comment">// 2.&#x4FDD;&#x5B58;&#x8FD4;&#x56DE;&#x503C;</span>
  <span class="hljs-keyword">let</span> result = <span class="hljs-string">&apos;&apos;</span>;

  <span class="hljs-comment">// 3.&#x53D6;&#x51FA;&#x4F20;&#x9012;&#x7684;&#x53C2;&#x6570; &#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x662F;this&#xFF0C; &#x4E0B;&#x9762;&#x662F;&#x4E09;&#x79CD;&#x622A;&#x53D6;&#x9664;&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x4E4B;&#x5916;&#x5269;&#x4F59;&#x53C2;&#x6570;&#x7684;&#x65B9;&#x6CD5;</span>
  <span class="hljs-keyword">const</span> args = [...arguments].slice(<span class="hljs-number">1</span>);
  <span class="hljs-comment">//const args = Array.prototype.slice.call(arguments, 1);</span>
  <span class="hljs-comment">//const args = Array.from(arguments).slice(1);</span>

  <span class="hljs-comment">// 4.&#x6267;&#x884C;&#x8FD9;&#x4E2A;&#x65B9;&#x6CD5;&#xFF0C;&#x5E76;&#x4F20;&#x5165;&#x53C2;&#x6570; ...&#x662F;es6&#x7684;&#x8BED;&#x6CD5;&#x7528;&#x6765;&#x5C55;&#x5F00;&#x6570;&#x7EC4;</span>
  result = context.fn(...args);

  <span class="hljs-comment">//5.&#x5220;&#x9664;&#x8BE5;&#x5C5E;&#x6027;</span>
  <span class="hljs-keyword">delete</span> context.fn;

  <span class="hljs-comment">//6.&#x8FD4;&#x56DE;</span>
  <span class="hljs-keyword">return</span> result;
}


<span class="hljs-keyword">const</span> obj = {
  value: <span class="hljs-string">&apos;hdove&apos;</span>
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">fn</span>(<span class="hljs-params">name, age</span>) </span>{
  <span class="hljs-keyword">return</span>  {
      value: <span class="hljs-keyword">this</span>.value,
      name,
      age
  }
}

fn.myCall(obj, <span class="hljs-string">&apos;LJ&apos;</span>, <span class="hljs-number">25</span>); <span class="hljs-comment">// {value: &quot;hdove&quot;, name: &quot;LJ&quot;, age: 25}</span>
</code></pre>
<h5 id="6&#x3001;&#x624B;&#x5199;-apply"><a name="6&#x3001;&#x624B;&#x5199;-apply" class="anchor-navigation-ex-anchor" href="#6&#x3001;&#x624B;&#x5199;-apply"><i class="fa fa-link" aria-hidden="true"></i></a><a name="6&#x3001;&#x624B;&#x5199;-apply" class="plugin-anchor" href="#6&#x3001;&#x624B;&#x5199;-apply"><i class="fa fa-link" aria-hidden="true"></i></a>6&#x3001;&#x624B;&#x5199; apply</h5>
<pre><code class="lang-js"><span class="hljs-built_in">Function</span>.prototype.myApply = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">context, args</span>) </span>{
  <span class="hljs-keyword">var</span> context = <span class="hljs-built_in">Object</span>(context) || <span class="hljs-built_in">window</span>;

  context.fn = <span class="hljs-keyword">this</span>;

  <span class="hljs-keyword">let</span> result = <span class="hljs-string">&apos;&apos;</span>;

  <span class="hljs-comment">//4. &#x5224;&#x65AD;&#x6709;&#x6CA1;&#x6709;&#x4F20;&#x5165;args</span>
  <span class="hljs-keyword">if</span>(!args) {
    result = context.fn();
  }<span class="hljs-keyword">else</span> {
    result = context.fn(...args);
  }

  <span class="hljs-keyword">delete</span> context.fn;

  <span class="hljs-keyword">return</span> result;
}

<span class="hljs-keyword">const</span> obj = {
  value: <span class="hljs-string">&apos;hdove&apos;</span>
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">fn</span>(<span class="hljs-params">name, age</span>) </span>{
  <span class="hljs-keyword">return</span>  {
      value: <span class="hljs-keyword">this</span>.value,
      name,
      age
  }
}

fn.myApply(obj, [<span class="hljs-string">&apos;LJ&apos;</span>, <span class="hljs-number">25</span>]); <span class="hljs-comment">// {value: &quot;hdove&quot;, name: &quot;LJ&quot;, age: 25}</span>
</code></pre>
<h5 id="7&#x3001;&#x624B;&#x5199;-bind"><a name="7&#x3001;&#x624B;&#x5199;-bind" class="anchor-navigation-ex-anchor" href="#7&#x3001;&#x624B;&#x5199;-bind"><i class="fa fa-link" aria-hidden="true"></i></a><a name="7&#x3001;&#x624B;&#x5199;-bind" class="plugin-anchor" href="#7&#x3001;&#x624B;&#x5199;-bind"><i class="fa fa-link" aria-hidden="true"></i></a>7&#x3001;&#x624B;&#x5199; bind</h5>
<p><a href="https://www.lagou.com/lgeduarticle/90903.html" target="_blank">https://www.lagou.com/lgeduarticle/90903.html</a></p>
<pre><code class="lang-js"><span class="hljs-built_in">Function</span>.prototype.myBind = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">context</span>) </span>{
  <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> <span class="hljs-keyword">this</span> !== <span class="hljs-string">&quot;function&quot;</span>) {
    <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">&quot;&#x4E0D;&#x662F;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&quot;</span>)
  }
  <span class="hljs-keyword">const</span> self = <span class="hljs-keyword">this</span>;
  <span class="hljs-keyword">const</span> args1 = [...arguments].slice(<span class="hljs-number">1</span>)

  <span class="hljs-keyword">const</span> bindFn = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">const</span> args2 = [...arguments] 
    <span class="hljs-keyword">return</span> self.apply(context, args1.concat(args2))
  }

  <span class="hljs-keyword">return</span> bindFn
}

<span class="hljs-keyword">const</span> obj = {
  value: <span class="hljs-string">&apos;hdove&apos;</span>
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">fn</span>(<span class="hljs-params">name, age</span>) </span>{
  <span class="hljs-keyword">return</span>  {
    value: <span class="hljs-keyword">this</span>.value,
    name,
    age
  }
}

<span class="hljs-keyword">var</span> result = fn.myBind(obj)(<span class="hljs-string">&apos;lu&apos;</span>, <span class="hljs-number">25</span>)
<span class="hljs-built_in">console</span>.log(result)
</code></pre>
<h3 id="&#x4E09;&#x3001;&#x51FD;&#x6570;&#x67EF;&#x91CC;&#x5316;&#x4E0E;&#x53CD;&#x67EF;&#x91CC;&#x5316;"><a name="&#x4E09;&#x3001;&#x51FD;&#x6570;&#x67EF;&#x91CC;&#x5316;&#x4E0E;&#x53CD;&#x67EF;&#x91CC;&#x5316;" class="anchor-navigation-ex-anchor" href="#&#x4E09;&#x3001;&#x51FD;&#x6570;&#x67EF;&#x91CC;&#x5316;&#x4E0E;&#x53CD;&#x67EF;&#x91CC;&#x5316;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x4E09;&#x3001;&#x51FD;&#x6570;&#x67EF;&#x91CC;&#x5316;&#x4E0E;&#x53CD;&#x67EF;&#x91CC;&#x5316;" class="plugin-anchor" href="#&#x4E09;&#x3001;&#x51FD;&#x6570;&#x67EF;&#x91CC;&#x5316;&#x4E0E;&#x53CD;&#x67EF;&#x91CC;&#x5316;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E09;&#x3001;&#x51FD;&#x6570;&#x67EF;&#x91CC;&#x5316;&#x4E0E;&#x53CD;&#x67EF;&#x91CC;&#x5316;</h3>
<h4 id="1&#x3001;&#x524D;&#x8A00;"><a name="1&#x3001;&#x524D;&#x8A00;" class="anchor-navigation-ex-anchor" href="#1&#x3001;&#x524D;&#x8A00;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="1&#x3001;&#x524D;&#x8A00;" class="plugin-anchor" href="#1&#x3001;&#x524D;&#x8A00;"><i class="fa fa-link" aria-hidden="true"></i></a>1&#x3001;&#x524D;&#x8A00;</h4>
<p>&#x5728;&#x51FD;&#x6570;&#x5F0F;&#x7F16;&#x7A0B;&#x4E2D;&#x7ECF;&#x5E38;&#x4F1A;&#x9047;&#x5230;&#x5F88;&#x591A;&#x6982;&#x5FF5;&#xFF0C;&#x6BD4;&#x5982;&#x7EAF;&#x51FD;&#x6570;&#x3001;&#x67EF;&#x91CC;&#x5316;&#x3001;&#x9AD8;&#x9636;&#x51FD;&#x6570;&#x3002;</p>
<ul>
<li>&#x7EAF;&#x51FD;&#x6570;</li>
</ul>
<p>&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x7684;&#x8FD4;&#x56DE;&#x7ED3;&#x679C;&#x53EA;&#x4F9D;&#x8D56;&#x4E8E;&#x5B83;&#x7684;&#x53C2;&#x6570;&#xFF0C;&#x5E76;&#x4E14;&#x5728;&#x6267;&#x884C;&#x8FC7;&#x7A0B;&#x91CC;&#x9762;&#x6CA1;&#x6709;&#x526F;&#x4F5C;&#x7528;</p>
<ul>
<li>&#x67EF;&#x91CC;&#x5316;</li>
</ul>
<p>&#x63A5;&#x53D7;&#x591A;&#x4E2A;&#x53C2;&#x6570;&#x7684;&#x51FD;&#x6570;&#x8F6C;&#x6362;&#x6210;&#x63A5;&#x53D7;&#x5355;&#x4E00;&#x53C2;&#x6570;&#x7684;&#x51FD;&#x6570;&#x7684;&#x64CD;&#x4F5C;</p>
<ul>
<li>&#x9AD8;&#x9636;&#x51FD;&#x6570;</li>
</ul>
<p>&#x4E00;&#x4E2A;&#x53EF;&#x4EE5;&#x63A5;&#x6536;&#x51FD;&#x6570;&#x4F5C;&#x4E3A;&#x53C2;&#x6570;&#xFF0C;&#x5E76;&#x4E14;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x7684;&#x51FD;&#x6570;</p>
<h4 id="2&#x3001;&#x51FD;&#x6570;&#x67EF;&#x91CC;&#x5316;"><a name="2&#x3001;&#x51FD;&#x6570;&#x67EF;&#x91CC;&#x5316;" class="anchor-navigation-ex-anchor" href="#2&#x3001;&#x51FD;&#x6570;&#x67EF;&#x91CC;&#x5316;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="2&#x3001;&#x51FD;&#x6570;&#x67EF;&#x91CC;&#x5316;" class="plugin-anchor" href="#2&#x3001;&#x51FD;&#x6570;&#x67EF;&#x91CC;&#x5316;"><i class="fa fa-link" aria-hidden="true"></i></a>2&#x3001;&#x51FD;&#x6570;&#x67EF;&#x91CC;&#x5316;</h4>
<p>&#x51FD;&#x6570;&#x67EF;&#x91CC;&#x5316;&#x53C8;&#x79F0;&#x90E8;&#x5206;&#x6C42;&#x503C;&#xFF0C;&#x51FD;&#x6570;&#x9996;&#x5148;&#x4F1A;&#x63A5;&#x6536;&#x4E00;&#x4E9B;&#x53C2;&#x6570;&#xFF0C;&#x4E4B;&#x540E;&#x8BE5;&#x51FD;&#x6570;&#x5E76;&#x4E0D;&#x4F1A;&#x7ACB;&#x5373;&#x6C42;&#x503C;&#xFF0C;&#x800C;&#x662F;&#x7EE7;&#x7EED;&#x8FD4;&#x56DE;&#x53E6;&#x5916;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#xFF0C;&#x4E0A;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x4EE5;&#x95ED;&#x5305;&#x7684;&#x5F62;&#x5F0F;&#x4FDD;&#x5B58;&#xFF0C;&#x5F85;&#x5230;&#x51FD;&#x6570;&#x88AB;&#x771F;&#x6B63;&#x9700;&#x8981;&#x6C42;&#x503C;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x5C06;&#x4E4B;&#x524D;&#x4F20;&#x5165;&#x7684;&#x6240;&#x6709;&#x53C2;&#x6570;&#x62FF;&#x6765;&#x4E00;&#x6B21;&#x6027;&#x6C42;&#x503C;&#x3002;&#x5C31;&#x597D;&#x50CF;&#x6211;&#x4EEC;&#x8BA1;&#x7B97;&#x6BCF;&#x4E2A;&#x6708;&#x7684;&#x5F00;&#x9500;&#xFF0C;&#x5E76;&#x4E0D;&#x4F1A;&#x6BCF;&#x6D88;&#x8D39;&#x4E00;&#x7B14;&#x5C31;&#x8BA1;&#x7B97;&#x603B;&#x503C;&#xFF0C;&#x800C;&#x662F;&#x7B49;&#x5230;&#x6708;&#x5E95;&#x518D;&#x628A;&#x5168;&#x90E8;&#x6D88;&#x8D39;&#x52A0;&#x8D77;&#x6765;&#x8BA1;&#x7B97;&#x603B;&#x503C;&#x3002;</p>
<p><strong>&#x901A;&#x7528;&#x7684;&#x67EF;&#x91CC;&#x5316;&#x51FD;&#x6570;&#x5982;&#x4E0B;&#xFF1A;</strong></p>
<pre><code class="lang-js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">currying</span>(<span class="hljs-params">fn</span>) </span>{
  <span class="hljs-keyword">var</span> slice = <span class="hljs-built_in">Array</span>.prototype.slice
  <span class="hljs-keyword">var</span> __args = slice.call(<span class="hljs-built_in">arguments</span>, <span class="hljs-number">1</span>)
  <span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">var</span> __inargs = slice.call(<span class="hljs-built_in">arguments</span>)
    <span class="hljs-keyword">return</span> fn.apply(<span class="hljs-literal">null</span>, __args.concat(__inargs))
  };
}
</code></pre>
<p><strong>&#x4E3E;&#x4E2A;&#x6817;&#x5B50;</strong></p>
<p>&#x5BF9;&#x4E8E;add&#x51FD;&#x6570;&#xFF0C;&#x5B9E;&#x73B0;&#x4EFB;&#x610F;&#x6BCF;&#x6B21;&#x4EFB;&#x610F;&#x8F93;&#x5165;&#x51E0;&#x4E2A;&#x53C2;&#x6570;&#xFF0C;&#x5F97;&#x5230;&#x53C2;&#x6570;&#x503C;&#x7684;&#x7D2F;&#x52A0;&#x7ED3;&#x679C;</p>
<pre><code class="lang-js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">add</span>(<span class="hljs-params">...rest</span>) </span>{
  <span class="hljs-keyword">var</span> args = [];
  args.push(...rest);
  <span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">cb</span>(<span class="hljs-params">...rest</span>) </span>{
    <span class="hljs-keyword">if</span>(rest.length == <span class="hljs-number">0</span>){
        <span class="hljs-keyword">return</span> args.reduce(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">acc, cur</span>) </span>{
            <span class="hljs-keyword">return</span> acc + cur;
        }); 
    }<span class="hljs-keyword">else</span>{
        args.push(...rest);
        <span class="hljs-keyword">return</span> cb;
    }
  }
}
<span class="hljs-built_in">console</span>.log(add(<span class="hljs-number">1</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>)(<span class="hljs-number">7</span>,<span class="hljs-number">8</span>)())  <span class="hljs-comment">//25</span>
</code></pre>
<p><strong>&#x5E94;&#x7528;&#x573A;&#x666F;</strong></p>
<ul>
<li><p>&#x63D0;&#x9AD8;&#x9002;&#x7528;&#x6027;
&#x6BD4;&#x5982;&#x5BF9;&#x4E8E;&#x53CD;&#x590D;&#x8F93;&#x5165;&#x76F8;&#x540C;&#x53C2;&#x6570;&#x7684;&#x51FD;&#x6570;&#xFF0C;&#x901A;&#x8FC7;&#x67EF;&#x91CC;&#x5316;&#xFF0C;&#x53EA;&#x9700;&#x4F20;&#x5165;&#x4E0D;&#x540C;&#x7684;&#x53C2;&#x6570;&#x3002;</p>
</li>
<li><p>&#x5EF6;&#x8FDF;&#x6267;&#x884C;
&#x5982;&#x4E0A;&#x9762;&#x7684;add&#x51FD;&#x6570;&#xFF0C;&#x4E00;&#x76F4;&#x7B49;&#x5230;&#x4E0D;&#x518D;&#x4F20;&#x5165;&#x53C2;&#x6570;&#x65F6;&#x6267;&#x884C;&#x7D2F;&#x52A0;&#x3002;</p>
</li>
<li><p>&#x56FA;&#x5B9A;&#x6613;&#x53D8;&#x56E0;&#x7D20;
&#x5982;bind&#x51FD;&#x6570;&#x7684;&#x5B9E;&#x73B0;</p>
</li>
</ul>
<h4 id="3&#x3001;&#x53CD;&#x67EF;&#x91CC;&#x5316;"><a name="3&#x3001;&#x53CD;&#x67EF;&#x91CC;&#x5316;" class="anchor-navigation-ex-anchor" href="#3&#x3001;&#x53CD;&#x67EF;&#x91CC;&#x5316;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="3&#x3001;&#x53CD;&#x67EF;&#x91CC;&#x5316;" class="plugin-anchor" href="#3&#x3001;&#x53CD;&#x67EF;&#x91CC;&#x5316;"><i class="fa fa-link" aria-hidden="true"></i></a>3&#x3001;&#x53CD;&#x67EF;&#x91CC;&#x5316;</h4>
<p>&#x901A;&#x4FD7;&#x6765;&#x8BF4;, &#x4F7F;&#x7528;uncurrying&#x6280;&#x672F;, &#x53EF;&#x4EE5;&#x8BA9;&#x4EFB;&#x4F55;&#x5BF9;&#x8C61;&#x62E5;&#x6709;&#x539F;&#x751F;&#x5BF9;&#x8C61;&#x7684;&#x65B9;&#x6CD5;&#x3002;&#x6BD4;&#x5982;&#xFF1A;</p>
<pre><code>var obj = {}
var push = Array.prototype.push.uncurrying();
push(obj, &apos;first&apos;);
console.log(obj[0]);// first
</code></pre><p>&#x7531;&#x4E8E;&#x5728;javascript&#x91CC;&#x9762;&#xFF0C;&#x5F88;&#x591A;&#x51FD;&#x6570;&#x90FD;&#x4E0D;&#x505A;&#x5BF9;&#x8C61;&#x7684;&#x7C7B;&#x578B;&#x68C0;&#x6D4B;&#xFF0C;&#x800C;&#x662F;&#x53EA;&#x5173;&#x5FC3;&#x8FD9;&#x4E9B;&#x5BF9;&#x8C61;&#x80FD;&#x505A;&#x4EC0;&#x4E48;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x5E38;&#x8BF4;&#x7684;&#x9E2D;&#x5B50;&#x7C7B;&#x578B;&#x3002;&#x6240;&#x4EE5;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x89E3;&#x51B3;&#x7684;&#x53EA;&#x5269;&#x4E0B;&#x4E00;&#x4E2A;&#x95EE;&#x9898;&#xFF0C; &#x5982;&#x4F55;&#x901A;&#x8FC7;&#x4E00;&#x79CD;&#x901A;&#x7528;&#x7684;&#x65B9;&#x5F0F;&#x6765;&#x4F7F;&#x5F97;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x53EF;&#x4EE5;&#x5192;&#x5145;array&#x5BF9;&#x8C61;&#x3002;</p>
<p>&#x53CD;&#x67EF;&#x91CC;&#x5316;&#x7684;&#x5B9E;&#x73B0;&#x4EE3;&#x7801;&#x975E;&#x5E38;&#x7B80;&#x5355;&#xFF0C;&#x53EA;&#x6709;&#x5982;&#x4E0B;&#x51E0;&#x884C;&#xFF1A;</p>
<pre><code class="lang-js"><span class="hljs-built_in">Function</span>.prototype.uncurrying = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">var</span> _this = <span class="hljs-keyword">this</span>;
  <span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">return</span> <span class="hljs-built_in">Function</span>.prototype.call.apply(_this, <span class="hljs-built_in">arguments</span>);
  }
}
</code></pre>
<p>&#x6211;&#x4EEC;&#x4EE5;&#x4E0A;&#x9762;&#x90A3;&#x4E2A;&#x7ED9;obj&#x8D4B;&#x4E88;push&#x51FD;&#x6570;&#x4E3A;&#x4F8B;&#xFF0C;&#x5206;&#x6790;&#x53CD;&#x67EF;&#x91CC;&#x5316;&#x51FD;&#x6570;&#x8C03;&#x7528;&#x65F6;&#x7684;&#x5177;&#x4F53;&#x64CD;&#x4F5C;&#x3002;</p>
<pre><code class="lang-js"><span class="hljs-built_in">Function</span>.prototype.uncurrying = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">var</span> _this = <span class="hljs-keyword">this</span>  <span class="hljs-comment">//Array.prototype.push&#x4F5C;&#x4E3A;this&#x8D4B;&#x503C;&#x7ED9;_this</span>
  <span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-comment">/* &#x4F7F;_this&#x5177;&#x6709;&#x51FD;&#x6570;&#x7684;call&#x65B9;&#x6CD5;&#xFF0C;&#x5E76;&#x6267;&#x884C;&#x8BE5;call&#x65B9;&#x6CD5;&#xFF0C;&#x5373;&#x6267;&#x884C;Array.prototype.push.call&#x3002;
        &#x7531;&#x4E8E;apply&#x4EE5;&#x6570;&#x7EC4;&#x5F62;&#x5F0F;&#x63A5;&#x6536;&#x53C2;&#x6570;&#xFF0C;arguments&#x662F;[obj,&apos;first&apos;]
        call&#x51FD;&#x6570;&#x63A5;&#x6536;&#x53C2;&#x6570;&#x7B2C;&#x4E00;&#x4E2A;&#x4E3A;&#x6267;&#x884C;&#x4E0A;&#x4E0B;&#x6587;&#xFF0C;&#x540E;&#x9762;&#x4E3A;&#x4EE5;&#x9017;&#x53F7;&#x5F62;&#x5F0F;&#x7684;&#x53C2;&#x6570;&#x5217;&#x8868;&#xFF0C;&#x6240;&#x4EE5;obj&#x4F5C;&#x4E3A;call&#x51FD;&#x6570;&#x7684;&#x4E0A;&#x4E0B;&#x6587;&#xFF0C;&#x53C2;&#x6570;&#x662F;first
        &#x6700;&#x540E;&#x76F8;&#x5F53;&#x4E8E;&#x6267;&#x884C;&#x4E86; Array.prototype.push.call(obj, &apos;first&apos;)
    */</span>
    <span class="hljs-keyword">return</span> <span class="hljs-built_in">Function</span>.prototype.call.apply(_this, <span class="hljs-built_in">arguments</span>)
  }
}
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../" class="navigation navigation-prev " aria-label="Previous page: 前言">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="interview.html" class="navigation navigation-next " aria-label="Next page: interview">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"基础","level":"1.2","depth":1,"next":{"title":"interview","level":"1.2.1","depth":2,"path":"basics/interview.md","ref":"./basics/interview.md","articles":[]},"previous":{"title":"前言","level":"1.1","depth":1,"path":"README.md","ref":"README.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-sharing","splitter","expandable-chapters-small","anchors","github","github-buttons","sharing-plus","anchor-navigation-ex","favicon","insert-logo"],"styles":{"website":"./styles/website.css"},"pluginsConfig":{"github":{"url":"https://github.com/lurongtao/felixbooks-kbone"},"splitter":{},"search":{},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":false},"favicon":{"shortcut":"./source/images/favicon.jpg","bookmark":"./source/images/favicon.jpg","appleTouch":"./source/images/apple-touch-icon.jpg","appleTouchMore":{"120x120":"./source/images/apple-touch-icon.jpg","180x180":"./source/images/apple-touch-icon.jpg"}},"github-buttons":{"buttons":[{"user":"lurongtao","repo":"felixbooks-kbone","type":"star","size":"small","count":true}]},"expandable-chapters-small":{},"sharing":{"qq":false,"all":["google","facebook","weibo","twitter","qq","qzone","linkedin","pocket"],"douban":false,"facebook":false,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":false,"messenger":false,"line":false,"vk":false,"pocket":false,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchors":{},"insert-logo":{"url":"/felixbooks-kbone/images/logo-kbone.png","style":"background: skyblue; width: 100%; height: 100%;"}},"theme":"default","author":"古艺散人","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"千锋大前端小册-Electron","language":"zh-hans","links":{},"gitbook":"3.2.3","description":"Electron 入门与实战"},"file":{"path":"basics/interview.md","mtime":"2020-06-25T23:36:01.616Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-06-25T23:36:40.914Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-github-buttons/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-insert-logo/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

